#ifndef CANVAS_H
#define CANVAS_H

#include <QWidget>
#include <QMouseEvent>
#include <QShortcut>
#include "point3d.h"

#define NULLPOINT QPoint(-1,-1)

namespace Ui {
    class Canvas;
}

class Canvas : public QWidget
{
    Q_OBJECT

    QImage buffer;

    QPoint lastLeft;

    QShortcut *m_L;
    QShortcut *m_Plus;
    QShortcut *m_Minus;
    QShortcut *m_S;

signals:
    void left(QPoint);
    void leftRelease();
    void right(QPoint);
    void rightRelease();

    void check();
    void l();
    void plus();
    void minus();
    void s();

public:
    explicit Canvas(QWidget *parent = 0);
    ~Canvas();

    bool originalShowedCkecked();
    bool customizedShowedCkecked();
    bool originalPointsChecked();
    bool customizedPointsChecked();

    void drawCurvePoligonal(const std::vector<Point3D>& points, const QColor& cor, bool withPoints = true);
    void clear();

private:
    Ui::Canvas *ui;

    void mousePressEvent(QMouseEvent *);
    void mouseReleaseEvent(QMouseEvent *);
    void mouseMoveEvent(QMouseEvent *);
    void resizeEvent(QResizeEvent *);
    void setupBuffer();
    void paintBuffer();
};

#endif // CANVAS_H
